package com.mi.simplefactory;

import java.io.IOException;
import java.util.Properties;

public class CarFactory {

	private CarFactory(){}
	
	private static Properties config = new Properties();
	static{
		try {
			config.load(CarFactory.class.getResourceAsStream("config.properties"));
		} catch (IOException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}
	
	public static Car newCar() throws ClassNotFoundException, InstantiationException, IllegalAccessException{
		String className = config.getProperty("Car");
		Class<?> clazz = Class.forName(className);
		return (Car)clazz.newInstance();
	}
}
